import React, {Component} from "react";
import {
    View,
    Text,
    Image,
    TouchableOpacity,
    StyleSheet,
}from 'react-native';
import NavigationBar from "./NavigationBar"
import HttpUtils from "./HttpUtils"

export default class Girl extends Component {
    constructor(props) {
        super(props);
        this.state = {
            loadData: ''
        }
    }

    Load(url) {
        HttpUtils.get(url)
            .then((res) => {
                this.setState({
                    loadData: JSON.stringify(res.data)
                })
            })
    }

    render() {
        return (
            <View style={styles.container}>
                <NavigationBar
                    title={"fetch"}
                />
                <Text
                    style={styles.text}
                    onPress={() => this.Load("https://www.easy-mock.com/mock/5a7c1947e3fe0e684e84b643/example/myUrl")}
                >加载数据</Text>
                <Text style={styles.text}>{this.state.loadData}</Text>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: "white",
    },
    text: {
        fontSize: 20,
    }
})